<div class="container">
	<div class="tabbable tabs-left" id="admin_bar">
		<%= render 'shared/admin_bar'%>
		<div class="tab-content">
			<div class="row-fluid">
				<h1 class="span12"> <%= t('san_pham_trong_danh_muc__', :danh_muc => @danh_muc_ngon_ngu.ten)%> </h1>
			</div>
			<div class="row-fluid">
				<div class="span6">
					<a href="<%= url_for :action=> "tao_moi" %>" class="btn btn-primary"><%= t 'san_pham_moi'%></a>
				</div>
				<div class="span6 text-right">
					<a href="<%= url_for :loc => (params[:loc].present? ? nil : 'da_xoa') %>" class="btn btn-small"><%= params[:loc].present? ? t('san_pham_chua_xoa') : t('san_pham_da_xoa')%></a>
				</div>
			</div>
			<% sl_ngon_ngu = APP_CONFIG['ngon_ngu']%>
			<table class="table table-stripped">
				<thead>
					<tr>
						<th> # </th>
						<th> <%= t 'san_pham'%> </th>
						<th> <%= t 'ban_dich' %> </th>
						<th> <%= t 'ten_san_pham_head'%> </th>
						<th> <%= t 'thao_tac'%></th>
						<th> <%= t 'gia'%></th>
						<th> <%= t 'khuyen_mai'%></th>
					</tr>
				</thead>
				<tbody>
					<% i = @index_dau_tien + 1%>
					<% for san_pham in @san_phams%>
					<% ban_dich = 0  %>
					<% sl_ngon_ngu.each { |k, v| %>
						<% sp_dich = san_pham.noi_dung(k)%>
					<tr class="<%=  (sp_dich.nil? || sp_dich.dang_kich_hoat == false) ? "muted" :""  %>">
						
						<% if ban_dich == 0%>
						<td rowspan="<%= sl_ngon_ngu.length + 1%>" > <%= i%>
						<% i = i + 1%> </td>
						<td class="hinh_anh_dai_dien" rowspan="<%= sl_ngon_ngu.length + 1 %>"><img class=" img-rounded" src="<%= san_pham.hinh_anh %>"></td>
						<% end %>
						<td> <%= v['ten'] %> </td>
						<td> <%= sp_dich.present? ? sp_dich.tieu_de : ""%></td>
						<td> <% if sp_dich.present? %> 
							<a href="<%= url_for :action=> 'ban_dich', :uid=> san_pham.id, :ngon_ngu => k%>"><%= t 'sua_ban_dich'%> <i class="icon-edit"></i></a> 
							<% if sp_dich.dang_kich_hoat %> 
							<a href="<%= url_for :action => 'vo_hieu_ban_dich', :uid => san_pham.id, :ngon_ngu => sp_dich.ngon_ngu %>"><%= t 'vo_hieu_hoa_ban_dich'%> <i class="icon-circle"></i></a> 
							<% else %> 
							<a href="<%= url_for :action => 'kich_hoat_ban_dich', :uid => san_pham.id, :ngon_ngu => sp_dich.ngon_ngu %>"><%= t 'kich_hoat_ban_dich'%> <i class="icon-circle-blank"></i></a> 
							<% end %>
						<% else %> <a href="<%= url_for :action=> 'ban_dich', :uid=> san_pham.id, :ngon_ngu => k%>"><%= t 'tao_ban_dich'%> <i class="icon-plus"></i></a> <% end %> </td>
						<% if ban_dich == 0%>
						<td class="gia_san_pham"  rowspan="<%= sl_ngon_ngu.length + 1 %>">
							<%= number_with_delimiter(san_pham.gia,  :delimiter => " ") %> <span class="tien_te">VND</span>
						</td>
						<td class="khuyen_mai"  rowspan="<%= sl_ngon_ngu.length + 1 %>">
							<% if san_pham.co_khuyen_mai(Time.now)%>
							<p class="gia_khuyen_mai">
								<strong><%= number_with_delimiter san_pham.gia_khuyen_mai, :delimiter => " " %> <span class="tien_te">VND</span></strong>
							</p>
							<p>
								<i class="icon-time"></i>
								<%= san_pham.khuyen_mai_bat_dau.strftime('%d-%m-%Y')%> <span>-</span>
								<%= san_pham.khuyen_mai_ket_thuc.strftime('%d-%m-%Y')%>
							</p>
							<% end %>
						</td>
						<% end %>
					</tr>
					<% ban_dich += 1%>
					<% } %>
					<tr>
						<td colspan="3">
							<a href="<%= url_for :action=> 'cap_nhat', :uid => san_pham.id %>"><%= t 'sua_san_pham'%> <i class="icon-edit"></i></a> |
							<% if !['da_xoa'].include?(params[:loc])%>
							<a href="<%= url_for :action=> 'xoa', :uid => san_pham.id %>" onclick="return confirm('<%= t 'ban_co_chac_chan_muon_xoa'%>')"><%= t 'xoa_san_pham'%> <i class="icon-trash"></i></a>
							<% else %>
							<a href="<%= url_for :action=> 'khong_xoa', :uid => san_pham.id %>" ><%= t 'phuc_hoi_san_pham'%> <i class="icon-refresh"></i></a>
							<% end %> 
							| <a href="<%= url_for :action=> 'index', :controller=>"/san_pham", :danh_muc_slug => san_pham.danh_muc.slug, :san_pham_slug => san_pham.slug %>"><%= t 'xem_san_pham'%> </a>
						</td>
						</tr>
					<% end %>
				</tbody>
			</table>
			<div>
				<div class="span4 pull-right">
					<div class="pager">
						<% if @co_trang_truoc %>
						<li class="previous">
							<a href="<%= url_for :loc => params[:loc], :page => @trang - 1%>">&larr; <%= t 'trang_truoc'%></a>
						</li>
						<%end %>
						<% if @co_trang_sau %>
						<li class="next">
							<a href="<%= url_for :loc => params[:loc], :page => @trang + 1%>"><%= t 'trang_sau'%> &rarr;</a>
						</li>
						<%end %>
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
	</div>
</div>
